/**
 * 手风琴样式的应用资源菜单处理
 */
$(function() {
	$('#indexMenu').accordion({	//	渲染资源菜单
		animate: false,
	    fit: true,
	    border: false,
	    onSelect: function(title, index) {
	    	var selectedPanel = $('#indexMenu').accordion('getSelected');
	    	var content = '';
	    	var resource = orange.getResourceData();
    		for(var i=0; i<resource.length; i++) {
	    		if(selectedPanel.panel('options').resourceId == resource[i].pid && resource[i].display=='1') {
	    			var title = resource[i].name;
	    			var href = resource[i].url;
	    			content += '<a class="easyui-linkbutton" data-options="toggle:true,group:1,plain:true" style="width:100%;margin-bottom:5px;text-align:left"'
	    				+ ' onclick=_indexMainTabs.addModule(\''+title+'\',\''+href+'\')>'+resource[i].name+'</a>';
	    		}
	    	}
			selectedPanel.panel('clear');
			selectedPanel.panel('body').append('<div style="padding:5px">'+content+'</div>');
			$.parser.parse(selectedPanel);
	    }
	}); 
	var data = orange.getResourceData();
	for(var i=0; i<data.length; i++) {
		if(data[i].pid == null || data[i].pid == ""){
			$('#indexMenu').accordion('add', {
			    selected: false,
			    title: data[i].name,
			    resourceId: data[i].id
			}); 
		}
	}
});
